package com.mnsq.subject.controller;

import com.mnsq.common.bean.annotation.UserInfoRequired;
import com.mnsq.common.bean.conf.ThreadLocalUserId;
import com.mnsq.common.bean.entity.subject.UserDynamic;
import com.mnsq.common.controller.BaseController;
import com.mnsq.common.service.BaseService;
import com.mnsq.subject.bean.condition.DynamicCondition;
import com.mnsq.subject.service.DynamicService;
import io.swagger.annotations.ApiOperation;
import matrix.module.common.bean.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO 动态列表接口定义
 *
 * @author 周俭
 */
@RestController
@RequestMapping("/api/dynamic")
public class DynamicController extends BaseController<UserDynamic, BaseService<UserDynamic, DynamicCondition>, DynamicCondition> {

    @Autowired
    private DynamicService dynamicService;

    @ApiOperation("关注动态列表查询")
    @PostMapping("/focus/page")
    @UserInfoRequired(required = true)
    public Result queryFocusPage(@RequestBody DynamicCondition dc) {
        return Result.success(dynamicService.queryFocusPage(dc));
    }

    @ApiOperation("本人动态列表查询")
    @PostMapping("/mine/page")
    @UserInfoRequired(required = true)
    public Result minePage(@RequestBody DynamicCondition dc) {
        dc.setCreateUserId(ThreadLocalUserId.CURRENT_USER_ID.get());
        return super.queryPage(dc);
    }

    @ApiOperation("点赞/取消点赞")
    @PostMapping("/like")
    @UserInfoRequired(required = true)
    public Result like(@RequestBody DynamicCondition dc) {
        return null;
    }
}
